/**
 * 第一场景 ScreenOne
 */
class ScreenOne extends egret.DisplayObjectContainer {
    /** 加载背景 */
    private bg_png = Main.createBitmapByName("bg_1_png");
    /** 加载草 */
    private cao_png = Main.createBitmapByName("cao_png");
    /** 加载栏杆 */
    private langan_png = Main.createBitmapByName("langan_png");
    /** 加载剪刀 */
    private cutAbout = new CutAbout();
    /** 加载角色 */
    private role_png = Main.createBitmapByName("0_png");
    /** 角色动画定时器 */
    private role_timer = new egret.Timer(1000 / 8, 23);
    /** 创建提示点 */
    private tipPoint = Main.createTipPoint();

    public constructor() {
        super();
        this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
    }

    private init() {
        /** 载入资源 */
        Main.createScale(this.bg_png, this);
        this.addChild(this.cutAbout);
        Main.createScale(this.cao_png, this);
        Main.createScale(this.role_png, this);
        Main.createScale(this.langan_png, this);
        /** 场景草的位置设置 */
        this.cao_png.scaleX = .94;
        this.cao_png.scaleY = .94;
        this.cao_png.x = 83;
        this.cao_png.y = 380;
        /** 提示点位置设置 */
        this.tipPoint.x = 640;
        this.tipPoint.y = 450;

        this.roleAnimationAbout();
        this.cutAboutListen();

        // Main.dragGetPatn(this.cao_png, this);
        ScreenLayer.creatOpenAlert(this, 1);
        // Main.screenTitle(this, "第一幕");
    }
    /** 角色动画相关 */
    private roleAnimationAbout() {
        /** 播放角色动画 */
        let num = 0;
        this.role_timer.addEventListener(egret.TimerEvent.TIMER, () => {
            num++;
            this.role_png.texture = RES.getRes(`${num}_png`)
        }, this);
        /** 角色动画播放完毕 */
        this.role_timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, () => {
            egret.Tween.get(this).wait(2000).call(() => {
                ScreenLayer.createAlert(this);
            })
        }, this);
    }
    /** 剪刀监听相关 */
    private cutAboutListen() {
        /**监听剪刀移动 */
        this.cutAbout.addEventListener("move", () => {
            this.setChildIndex(this.cutAbout, 99);
            this.addChild(this.tipPoint);
        }, this);
        /**监听剪刀碰撞 */
        this.cutAbout.addEventListener("hit", () => {
            this.removeChild(this.cutAbout);
            this.removeChild(this.tipPoint);
            this.role_timer.start();
        }, this);
    }

}